<template>
  <div>
    <h2 ref="title">{{info.name}}</h2>
    <button @click="changeData">换名字</button>
  </div>
</template>

<script>
import {reactive, ref, watch} from "vue";

export default {
  setup(){
    const info = reactive({name:"wmy",age:18})
    const name = ref("wql");

    //传入数组
    watch([info,name],(newValue,oldValue) => {
      console.log("newValue:" ,newValue,"oldValue:",oldValue);
    })


    const changeData = () => {
      name.value = "wj"
    }

    return{
      changeData,
      info
    }
  }
}
</script>

<style scoped>

</style>
